# 0qgis - fixup install_names for @loader_path
# ! cmakecache vars not available to external scripts
#   so we configure it first to do substitutions
#   make sure to use @varname@

# kill boolean warnings
CMAKE_POLICY (SET CMP0012 NEW)

INCLUDE ("@CMAKE_BINARY_DIR@/mac/0vars.cmake")
INCLUDE ("@CMAKE_SOURCE_DIR@/cmake/MacBundleMacros.cmake")

# assume all install_names start with CMAKE_INSTALL_NAME_DIR
# so we don't have to extract it from binaries
# leave main qgis executable and qgis_help with executable_paths

MESSAGE (STATUS "Updating QGIS library paths...")
# inter-library links - do all combos, many will be noops
FOREACH (QL ${QGFWLIST})
    GET_INSTALL_NAME ("${QFWDIR}/${QL}.framework/${QL}" ${QL}.framework QQ)
    SET (QFW_CHG "${QQ}")
    UPDATEQGISPATHS ("${QFW_CHG}" ${QL})
    # change id of the framework
    IF (NOT @QGIS_MACAPP_INSTALL_DEV@)
        EXECUTE_PROCESS(COMMAND install_name_tool -id "${ATEXECUTABLE}/${QGIS_FW_SUBDIR}/${QL}.framework/${QL}" "${QFWDIR}/${QL}.framework/${QL}")
    ENDIF ()
ENDFOREACH (QL)
FOREACH (QLIB ${QGLIBLIST})
    GET_INSTALL_NAME ("${QLIBDIR}/${QLIB}" ${QLIB} QQ)
    SET (QLIB_CHG "${QQ}")
    UPDATEQGISPATHS ("${QLIB_CHG}" ${QLIB})
ENDFOREACH (QLIB)
